home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
usenet
/
st80_pre4
/
Switch3DView.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
4KB
|
111 lines
" NAME Switch3DView
AUTHOR (Pieter S. van der Meulen)
FUNCTION adds a 3D look to SwitchViews
ST80-VERSIONS 2.3
PREREQUISITES
CONFLICTS
DISTRIBUTION world
VERSION ID 1.1
VERSION DATE 11 Oct 1989
DATE 11 Oct 1989
"
'Anybody who attended the OOPSLA89 exhibits may have noticed
that the new fashion in user-interfaces is 3D (depth effects).
I have seen only some effort in Smalltalk80 with respect to 3D.
Even though (I think) that it is not very important to have these
features, users are attracted/amused by them. And, I have even
heard someone saying that Smalltalk has not the most advanced
user-interface anymore (such sacrilege :-) ).
Anyway, I thought it should be really easy to get some of you
Smalltalkers motivated to come up with some examples.
To show how simple this is, I included an example for ParcPlace
Smalltalk-80 V2.3 (but will probably also work for other versions).
The Switch3DView, a subclass of SwitchView, adds 3D effects to
Switches. If you want all SwitchViews in the environment (like the
ones in BinaryChoice) to have this behavior, you may use the methods
here as SwitchView methods. In that case, omit the definition and
replace Switch3DView with SwitchView. I do not like MODIFYING
the system classes, so you do it.
Note: the <clearInside> method is really all you need........
Try the example <Switch3DView restoreDisplayView controller open>
and have fun,
Pieter S. van der Meulen.'!
SwitchView subclass: #Switch3DView
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Interface-Menus'!
Switch3DView comment:
'Add 3D effects to Switches.
Try <Switch3DView restoreDisplayView controller open>.
Written by Pieter S. van der Meulen.
'!
!Switch3DView methodsFor: 'displaying'!
clearInside
"Create a view with depth effects. Cash a BitBlt for speed.
Appropriate for most Smalltalk80 versions."
| aRect aBitBlt |
aRect _ self insetDisplayBox copy.
aBitBlt _ BitBlt
destForm: Display
sourceForm: nil
halftoneForm: nil
combinationRule: Form over
destOrigin: aRect origin
sourceOrigin: Display boundingBox origin
extent: aRect extent
clipRect: Display boundingBox.
(label isNil
ifTrue: [6]
ifFalse: [((aRect height - label height min:
(aRect width - label width)) // 2 - 1) min: 10])
timesRepeat:
[aBitBlt destRect: aRect; mask: Form darkGray; copyBits.
aRect corner: aRect corner - (1@1).
aBitBlt destRect: aRect; mask: Form lightGray; copyBits.
aRect origin: aRect origin + (1@1)].
aBitBlt destRect: aRect; mask: self insideColor; copyBits!
highlight
"Keep the switches de-emphasized appearance close to its
emphasized appearance. Only appropriate for ParcPlace Smalltalk."
highlightForm == nil ifFalse: [^highlightForm
displayOn: Display
at: self displayBox topLeft
clippingBox: self insetDisplayBox
rule: Form reverse
mask: nil].
emphasisOn
ifTrue: [Display reverse: (self insetDisplayBox insetBy: 1)]
ifFalse:
["Display reverse: (self insetDisplayBox insetBy: 1)."
Display reverse: (self insetDisplayBox insetBy: 2)]! !
!Switch3DView class methodsFor: 'examples'!
restoreDisplayView
"To create a Switch which allows you to restore the display,
execute : "
"Switch3DView restoreDisplayView controller open"
| topView aSwitch aView |
topView _ StandardSystemView new.
topView minimumSize: 128@40.
topView maximumSize: 128@40.
aSwitch _ Switch newOn.
aSwitch onAction: [ScheduledControllers restore].
"aSwitch offAction: [ScheduledControllers restore]."
aView _ self new model: aSwitch.
aView borderWidth: 1; label: 'Restore display' asDisplayText.
topView addSubView: aView.
^topView! !